package com.bra.ui.base;

import com.umeng.analytics.MobclickAgent;

import android.support.v4.app.Fragment;
import android.view.View;
import android.view.ViewGroup;
/**
 * 定义的fragment
 * @author lenovo
 *
 */
public abstract class BaseFragment extends Fragment {
	protected View rootView;
	private boolean hasInit;

	protected View getRootView(int layout) {
		if (rootView == null)
			rootView = View.inflate(getActivity(), layout, null);
		ViewGroup parent = (ViewGroup) rootView.getParent();
		if (parent != null) {
			parent.removeView(rootView);
		}
		if (!hasInit) {
			findView();
			fillData();
			hasInit = true;
		}
		return rootView;
	}

	protected abstract void fillData();

	protected abstract void findView();
	public void onResume() {
	    super.onResume();
	    MobclickAgent.onPageStart("MainScreen"); //统计页面，"MainScreen"为页面名称，可自定义
	}
	public void onPause() {
	    super.onPause();
	    MobclickAgent.onPageEnd("MainScreen"); 
	}
}
